#include <iostream>
#include <list>
#include <unistd.h>
#include "WorkQueue.h"
#include "FileInputNode.h"
#include "FileAdapter.h"
#include "Observer.h"
#include "Observable.h"

class MessageHandler : public utils::Observer<std::string> {
public:
	bool update(utils::Observable<std::string>* o, std::string message) {
		std::cout << "Message received: " << (std::string)message << std::endl;
		return true;
	}
};

int main(int argc, char** argv) {
	//node
	inte::FileInputNode fileInputNode;
	fileInputNode.setInputDirectory("c:\\eclipse_cpp\\in");
	fileInputNode.setPattern("^.*\\.xml$");
	//fileInputNode.setExPattern("");
	//list of nodes, not needed at the moment
//	std::list<inte::FileInputNode> nodeList;
//	nodeList.push_back(fileInputNode);

	std::cout << "I am about to start the Adapter\n";

	inte::FileAdapter* fileAdapterThread = new inte::FileAdapter(fileInputNode);
	MessageHandler* messageHandler = new MessageHandler();
	fileAdapterThread->addObserver(messageHandler);
	fileAdapterThread->start();


	sleep(1);
	std::cout << "I am about to stop the Adapter\n";
	fileAdapterThread->stop();
	std::cout << "Adapter is Stopped\n";
	delete fileAdapterThread;
	delete messageHandler;
}
